const wx2my = require('../../../wx2my');
const Behavior = require('../../../Behavior');
var wxbarcode = require('../../utils/index.js');

var app = getApp();
Page({
  data: {
    time: '',
    price: '',
    state: '',
    name: '',
    ticket_id: '',
    ticket_no: ''
  },
  onLoad: function (e) {
    console.log(e);
    this.setData({
      time: e.time,
      price: e.price,
      name: e.name,
      state: e.state,
      ticket_id: e.ticket_id,
      ticket_no: e.ticket_no,
      ticket_num: e.ticket_num
    });
    wxbarcode.barcode('barcode', this.data.ticket_no, 448, 120);
    wxbarcode.qrcode('qrcode', this.data.ticket_no, 400, 400);
    var o = this,
        t = e.hotel_id;
    o.setData({
      hotel_id: t,
      price: e.money
    }), o.setData({
      color: wx2my.getStorageSync("platform").color
    }), console.log(o.data), wx2my.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: '#ffffff',
      animation: {
        duration: 0,
        timingFunc: "easeIn"
      }
    }), o.reload();
  },
  reload: function (e) {
    var i = this,
        l = app.today(),
        o = wx2my.getStorageSync("userInfo").id,
        s = i.data.index,
        r = i.data.unreceive,
        c = i.data.page;
    app.util.request({
      url: "entry/wxapp/MyCoupons",
      cachetime: "0",
      data: {
        user_id: o,
        page: c
      },
      success: function (e) {}
    });
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {
    this.setData({
      seletive_index: 0,
      index: 0,
      page: 1,
      unreceive: []
    }), this.reload(), wx2my.stopPullDownRefresh();
  },
  onReachBottom: function () {
    this.reload();
  }
});